package com.excesys.exsecs.alarm.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.excesys.exsecs.alarm.entity.AlarmRecord;
import com.excesys.exsecs.alarm.service.AlarmRecordService;
import com.excesys.exsecs.common.core.util.R;
import com.excesys.exsecs.common.excel.annotation.ResponseExcel;
import com.excesys.exsecs.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 告警记录列表
 *
 * @author lxc
 * @date 2024-10-14 16:41:24
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/alarmHomePage" )
@Tag(description = "alarmHomePage" , name = "告警首页" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AlarmHomePageController {

    private final AlarmRecordService alarmRecordService;

    /**
     * 按时间查询次数曲线图
     * @param alarmRecord 告警记录列表
     * @return
     */
    @Operation(summary = "按时间查询次数曲线图" , description = "按时间查询次数曲线图" )
    @GetMapping("/getEchartsByTimeRange" )
    @PreAuthorize("@pms.hasPermission('alarm_alarmRecord_view')" )
    public R getEchartsByTimeRange(@ParameterObject AlarmRecord alarmRecord) {
        return R.ok(alarmRecordService.getEchartsByTimeRange(alarmRecord));
    }


    /**
     * 告警类型占比
     * @return R
     */
    @Operation(summary = "告警类型占比" , description = "告警类型占比" )
    @GetMapping("/getAlarmTypeProp" )
    @PreAuthorize("@pms.hasPermission('alarm_alarmRecord_view')" )
    public R getAlarmTypeProp(@ParameterObject AlarmRecord alarmRecord) {
        return R.ok(alarmRecordService.getAlarmTypeProp(alarmRecord));
    }

    /**
     * 告警等级排名
     * @param alarmRecord 告警记录列表
     * @return
     */
    @Operation(summary = "告警等级排名" , description = "告警等级排名" )
    @GetMapping("/getLevelStatis" )
    @PreAuthorize("@pms.hasPermission('alarm_alarmRecord_view')" )
    public R getLevelStatis(@ParameterObject AlarmRecord alarmRecord) {
        return R.ok(alarmRecordService.getLevelStatis(alarmRecord));
    }

    /**
     * 告警状态排名
     * @param alarmRecord 告警记录列表
     * @return
     */
    @Operation(summary = "告警状态排名" , description = "告警状态排名" )
    @GetMapping("/getStatusStatis" )
    @PreAuthorize("@pms.hasPermission('alarm_alarmRecord_view')" )
    public R getStatusStatis(@ParameterObject AlarmRecord alarmRecord) {
        return R.ok(alarmRecordService.getStatusStatis(alarmRecord));
    }

}